package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.entity.NursingProject;
import com.zzyl.entity.NursingProjectPagePram;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.zzyl.base.ResponseResult.success;

/**
 * @Description NursingController
 * @Author Bafeii7
 * @Date 2025-05-08 10:40
 */
@RestController
@RequestMapping("/nursing_project")
@Api(tags = "护理项目管理相关接口")
public class NursingProjectController {
    @Autowired
    private NursingProjectService nursingProjectService;


    @GetMapping
    public ResponseResult<PageResponse<NursingProject>> listByPage(NursingProjectPagePram nursingProjectPagePram) {
        PageResponse<Object> pageResponse = nursingProjectService.listByPage(nursingProjectPagePram);
        return success(pageResponse);
    }

    @GetMapping("/{id}")
    public ResponseResult<NursingProjectVo> getProjectById(@PathVariable Long id) {
        System.out.println(id);
        NursingProjectVo nursingProjectVo = nursingProjectService.getProjectById(id);
        return success(nursingProjectVo);
    }

    @RequestMapping(method = {RequestMethod.POST,RequestMethod.PUT})
    public ResponseResult<Object> saveOrUpdate(@RequestBody NursingProjectDto npDto) {
        nursingProjectService.updateOrAdd(npDto);
        return success();
    }

    @PutMapping("/{id}/status/{status}")
    public ResponseResult<Object> updateStatus(@PathVariable Long id, @PathVariable Integer status) {
        nursingProjectService.updateStatus(id, status);
        return success();
    }
    @DeleteMapping("/{id}")
    public ResponseResult<Object> delete(@PathVariable Long id) {
        nursingProjectService.delete(id);
        return success();
    }
    @GetMapping("/all")
    public ResponseResult<List<NursingProjectVo>> listAll() {
        List<NursingProjectVo> pageResponse = nursingProjectService.listAll();
        return success(pageResponse);
    }

}
